﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity.Migrations;
using BlogEntity315.Data.Model;

namespace BlogEntity315.Data
{
    public static class Seeder
    {
        public static void Seed(BlogDbContext db)
        {
            ///
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            db.Blogs.AddOrUpdate(
                b => new {b.BlogId, b.Title, b.Description},
                new Blog(){BlogId=1, Title="CC Tech Blog", Description="Talk about techy stuff"},
                new Blog(){BlogId=2, Title="Baking Blog", Description="Making cookies"},
                new Blog(){BlogId=3, Title="Motorsport", Description="Car & Bike talks"}
                );

            db.Articles.AddOrUpdate(
                a => new { a.ArticleId, a.BlogId, a.Title, a.Body, a.PublishDate },
                    new Article() { ArticleId = 1, BlogId = 1, Title = "Javascript is groovy", Body = "Lorum ipsum dolor...", PublishDate = DateTime.Now.AddDays(-20) },
                    new Article() { ArticleId = 2, BlogId = 1, Title = "Javascript is awefull", Body = "Lorum ipsum dolor. Lorum ipsum dolor...", PublishDate = DateTime.Now.AddDays(-2) },
                    new Article() { ArticleId = 3, BlogId = 2, Title = "Chocolate cookes", Body = "Oven 360 Lorum ipsum dolor. Lorum ipsum dolor...", PublishDate = DateTime.Now.AddDays(-2) },
                    new Article() { ArticleId = 4, BlogId = 3, Title = "Safety first", Body = "300 hp Lorum ipsum dolor. Lorum ipsum dolor...", PublishDate = DateTime.Now.AddDays(-1) }

                );



        }
    }
}
